﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GUI.QuanTriTaiKhoan;
using GUI.NghiepVuChuyenNganh;
using GUI.DuLieuVaHeThong;

namespace GUI
{
    public partial class frmMain : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        frmThongTin frm_thongtin;
        frmDangNhap frm_dangnhap;
        frmDoiMatKhau frm_doimatkhau;
        frmNhapMoi frm_nhapmoi;
        frmPhanQuyen frm_phanquyen;

        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            frm_thongtin = new frmThongTin();
            addForm(frm_thongtin.Text.ToString(), frm_thongtin);
        }

        public void addForm(string formName, Form child)
        {
            if (checkAddForm(formName))
            {
                child.Text = formName;
                child.TopLevel = false;
                child.MdiParent = this;
                child.Show();
            }
        }

        public bool checkAddForm(string Text)
        {
            bool add = true;
            if (xtraTMMMain.Pages.Count > 0)
            {
                for (int i = 0; i < xtraTMMMain.Pages.Count; i++)
                {
                    if (xtraTMMMain.Pages[i].Text == Text)
                    {
                        add = false;
                        xtraTMMMain.SelectedPage = xtraTMMMain.Pages[i];
                        return add;
                    }
                }
            }
            return add;
        }

        private void barBIDangNhap_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frm_dangnhap = new frmDangNhap();
            frm_dangnhap.ShowDialog();
        }

        private void barBIDoiMatKhau_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frm_doimatkhau = new frmDoiMatKhau();
            frm_doimatkhau.ShowDialog();
        }

        private void barBIThongTin_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frm_thongtin = new frmThongTin();
            addForm(frm_thongtin.Text.ToString(), frm_thongtin);
        }

        private void barBINhapMoi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frm_nhapmoi = new frmNhapMoi();
            addForm(frm_nhapmoi.Text.ToString(), frm_nhapmoi);
        }

        private void barBIPhanQuyen_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frm_phanquyen = new frmPhanQuyen();
            addForm(frm_phanquyen.Text.ToString(), frm_phanquyen);
        }
    }
}
